import request from 'umi-request';

export async function getShiftList(params) {
  return request('/hr-ssc/api/api-admin/leave/getShiftList', {
    method: 'get',
    params:{
      pageNum: params.current,
      ...params
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function getFrequencyList() {
  return request('/hr-ssc/api/api-admin/leave/getFrequencyList', {
    method: 'get',
  }).then((res) => {
    if (res.flag)
      return res.data;
    return null;
  });
}

export async function getShiftFrequency(params) {
  return request('/hr-ssc/api/api-admin/leave/getShiftFrequency', {
    method: 'get',
    params: params,
  }).then((res) => {
    if (res.flag)
      return res.data;
    return null;
  });
}

export async function saveAndUpdateShiftInfo(data) {
  return request('/hr-ssc/api/api-admin/leave/saveAndUpdateShiftInfo', {
    method: 'post',
    data: {...data},
  }).then((res) => res);
}

export async function deleteShift(id) {
  return request('/hr-ssc/api/api-admin/leave/deleteShift', {
    method: 'delete',
    params: {id},
  }).then((res) => res);
}

export async function shiftBpm(id) {
  return request(`/hr-ssc/api/api-admin/bpm/shiftBpm`, {
    method: 'get',
    params: {id},
  }).then((res) =>{
    return res;
  });
}


